import {
  HTTP
} from '../utils/http'
import mpx from '@mpxjs/core'
import apiProxy from '@mpxjs/api-proxy'

mpx.use(apiProxy, {
  usePromise: true
})

class AuthModel extends HTTP {
  // 检查是否已实名认证
  async checkIfAuth(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/user/check_real_name_authentication',
      data,
      method: 'POST'
    })
    return res
  }

  // 实名认证
  async authenticate(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/user/real_name_authentication',
      data,
      method: 'POST'
    })
    return res
  }

  // 获取合同的信息
  async getContractInfo(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/contract/checkV2',
      data,
      method: 'GET'
    })
    return res
  }

  // 签约合同时获取验证码
  async getVerificationCode(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/contract/sendcode',
      data,
      method: 'POST'
    })
    return res
  }

  // 签订合同
  async signContract(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/contract/signV3',
      data,
      method: 'GET'
    })
    return res
  }

  // 获取二维码有效时间
  async qrcodeExpire(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/job/qrcode_expire',
      data,
      method: 'GET'
    })
    return res
  }

  // 获取表单配置
  async getFormConfig(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/job/form_config',
      data,
      method: 'GET'
    })
    return res
  }
  // 获取e签约url
  async getEsignUrl(data) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/sign_url/get',
      data
    })
    return res
  }
  // 签约完成通知
  async reportSignSuccess(data = {}) {
    const res = await this.request({
      url: '/sea/api/1.0/client/v1/xinshui/sign_url/notify',
      data,
      method: 'POST'
    })
    return res
  }
}

export {
  AuthModel
}
